package com.example.demo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.Toast;

public class SearchCityActivity extends AppCompatActivity {
EditText searchEt;
ImageView submitIv;
GridView searchGv;
String[]hotCitys={"北京","上海","广州","深圳","珠海","佛山","南京","苏州","厦门","长沙","成都","福州","杭州","武汉","青岛","西安","太原","沈阳","重庆","天津","南宁"};
    private ArrayAdapter<String> adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_city);
       searchEt=findViewById(R.id.search_et);
       submitIv=findViewById(R.id.search_iv_submit);
        searchGv = findViewById(R.id.search_gv);
        submitIv.setOnClickListener((View.OnClickListener) this);
        //适配器
        adapter = new ArrayAdapter<>(this, R.layout.item_hotcity, hotCitys);
        searchGv.setAdapter(adapter);
    }
    public void onClick(View v){
        switch (v.getId()){
            case R.id.search_iv_submit:
                String city=searchEt.getText().toString();
                if (!TextUtils.isEmpty(city)){
//判断是否找到该城市
                }else {
                    Toast.makeText(this,"输入内容不能为空！",Toast.LENGTH_SHORT).show();
                }

            break;
        }



    }
}